import "./App.css";
import { Route, Routes } from "react-router-dom";
import { mainRoutes } from "@/router";
import { MenuRouteType } from "@/types/router";
import MainLayout from "./layout";
// import Test from "@/views/test";
import { ConfigProvider } from "antd";
import Login from "./views/login";
function App() {
  const renderRoutes = () => {
    let routes: MenuRouteType[] = [];
    mainRoutes.forEach((item) => {
      if (item.children) {
        routes = [...routes, ...item.children];
      } else {
        routes.push(item);
      }
    });
    return routes.map((item) => (
      <Route key={item.key} path={item.key} element={item.element} />
    ));
  };
  return (
    <>
      {/* <Test /> */}
      <ConfigProvider
        theme={{
          token: {
            // Seed Token，影响范围大
            colorPrimary: "#6D48C2",
            borderRadius: 2,
          },
        }}
      >
        <Routes>
          <Route path="/" element={<MainLayout />}>
            {renderRoutes()}
          </Route>
          <Route path="/login" element={<Login />} />
        </Routes>
      </ConfigProvider>
    </>
  );
}

export default App;
